#include <iostream>
#include <string>
using namespace std;

struct Node {
	string val;
	Node* left = nullptr;
	Node* right = nullptr;
};
string sp, tgt;
Node* H = nullptr;
void getTree(Node*& h)
{
	string cur;
	cin >> cur;
	if (cur == sp) return;
	h = new Node;
	h->val = cur;
	getTree(h->left);
	getTree(h->right);
}

Node* find(Node* h)
{
	if (!h) return nullptr;
	if (h->val == tgt) return h;
	auto l = find(h->left);
	if (l) return l;
	auto r = find(h->right);
	return r;
}

int main()
{
	cin >> sp;
	getTree(H);
	cin >> tgt;
	Node* ret = find(H);
	if (ret) cout << "TRUE";
	else cout << "FALSE";
	return 0;
}
